<template>
  <div class="speed-setting-dialog">
    <el-dialog
      title="全局播放速度设置"
      :visible.sync="isVisible"
      width="30%"
      :before-close="handleClose"
    >
      <el-form label-width="120px">
        <el-form-item label="播放速度">
          <el-slider
            v-model="speed"
            :min="0.5"
            :max="2.0"
            :step="0.1"
            show-input
          ></el-slider>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button type="primary" @click="handleSubmit">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    isVisible: {
      type: Boolean,
      default: false,
    },
    initialSpeed: {
      type: Number,
      default: 1.0,
    },
  },
  data() {
    return {
      speed: this.initialSpeed,
    };
  },
  methods: {
    handleClose() {
      this.$emit("update:isVisible", false);
    },
    handleSubmit() {
      this.$emit("update:isVisible", false);
      this.$emit("speed-set", this.speed);
    },
  },
};
</script>

<style scoped>
.speed-setting-dialog {
  display: flex;
  justify-content: center;
}
</style>
